/*
 * Copyright (c) United Binary LLC.  All rights reserved.
 * 
 * This code is licensed under the MIT License
 * 
 * SEE: http://harnessit.codeplex.com/license
 * 
 */
using System;
using UnitedBinary.UnitTests.Framework;
using UnitedBinary.HarnessIt.UnitTests.Settings;
using UnitedBinary.HarnessIt;

namespace UnitedBinary.HarnessIt.UnitTests.Projects
{
	/// <summary>
	/// Summary description for ProjectTests.
	/// </summary>
	public class ProjectTests
	{
		private string baseDir	= UnitTestSettings.TestDataDirectory;
		private string writeDir	= UnitTestSettings.TestDataWriteDirectory;

		public ProjectTests()
		{
		}

		[TestMethod("Initial values tests for the TestProjectConfig.")]
		public void Construction_InitialValues(TestMethodRecord tmr)
		{
			TestProjectConfig config = new TestProjectConfig();

			tmr.RunTest(config.Nodes.Length == 0, "TestProjectConfig has no nodes.");
		}

		[TestMethod("Test loading a good config file.")]
		public void FileIO_LoadGood(TestMethodRecord tmr)
		{
			TestProjectNode n;
			TestProjectConfig config = new TestProjectConfig();

			config.Load(baseDir + "Good.HarnessItConfig");

			n = GetNode("\\Assembly1",config);
			tmr.RunTest(n.Enabled == true, "Assembly1 is enabled.");
		}

		[TestMethod("Test saving a config file.")]
		public void FileIO_Save(TestMethodRecord tmr)
		{
		}

		private TestProjectNode GetNode(string path, TestProjectConfig TPC)
		{
			foreach(TestProjectNode n in TPC.Nodes)
			{
				if (n.NodePath.ToLower() == path.ToLower())
				{
					return n;
				}
			}
			throw new Exception("The specified node does not exist in the config: " + path);
		}

	}
}
